
#ifndef GroupGridded_h
#define GroupGridded_h

#include "Group.h"
#include "Array3.h"
#include "Vector.h"

class GroupGridded : public Group {
 public:
  GroupGridded(double cellfactor);
  virtual ~GroupGridded();

  virtual void preprocess();
  virtual void intersect(HitRecord& hit, const RenderContext& context, const Ray& ray) const;
 private:
  GroupGridded(const GroupGridded&);
  GroupGridded& operator=(const GroupGridded&);


  const Object** object_lists;
  Array3<int>  cells;
  double cellfactor;
  Point min, max;
  Vector diagonal_distance;
  Vector cellsize;
  Vector inv_cellsize;

  void transformToLattice(const BoundingBox& box,
                          int& sx, int& sy, int& sz, int& ex, int& ey, int& ez) const;
};

#endif